#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<string.h>
#include<stdlib.h>
#include<fcntl.h>
#include<unistd.h>
int main()
{
    umask(0);
    int fd=open("log.txt",O_WRONLY|O_CREAT|O_APPEND,0666);
    if(fd<0)
    {
        perror("open");
        return 1;
    }
    printf("fd:%d\n",fd);
    int a=123456789;
    char buffer[32];
    snprintf(buffer,sizeof(buffer),"%d",a);//将数字转换为字符串
    printf("%s\n",buffer);
    printf("%d\n",stdout->_fileno);
    write(fd,buffer,strlen(buffer));
    close(fd);
    return 0;
}
